#include <iostream>
#include "../bf.h"

DECLARE_DRAWABLE_BEGIN(BF, "Test/BF", 2,1,1)
  virtual void init() override {
    auto vao1 = render_.loadVertexArray("vao1");
    vao1->use();
    vao1->setLayout(0, 3, GL_FLOAT, sizeof(float), 8, 0);
    vao1->setLayout(1, 3, GL_FLOAT, sizeof(float), 8, 3);
    vao1->setLayout(2, 2, GL_FLOAT, sizeof(float), 8, 6);

    auto shader1 = render_.loadShader("texture.vs", "texture.fs", "shader1");
    shader1->use();
    shader1->setInt("texture1", 0);

    render_.loadTexture("container.jpg");
    render_.loadTexture("awesomeface.png");

    float vertices[] = {
      // positions          // colors           // texture coords
       0.5f,  0.5f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // top right
       0.5f, -0.5f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // bottom right
      -0.5f, -0.5f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // bottom left
      -0.5f,  0.5f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // top left 
    };
    unsigned int indices[] = {
      0, 1, 3, // first triangle
      1, 2, 3  // second triangle
    };
    render_.appendDrawData("vao1", "shader1", "awesomeface.png"
        , vertices, 32, indices, 6
        , 6);
    std::cout << render_.dump(8, 3) << std::endl;

    render_.flush();
  }
  virtual void uninit() override {
    render_.free();
  }
  virtual void render() override {
    render_.render();
  }
  virtual void processInput(sdl::event::Event &evt) override {
  }
 protected:
  sRender render_;
DECLARE_DRAWABLE_END(BF)